//
//  Float+Extent.swift
//  LeTu
//
//  Created by gy on 2023/12/27.
//

import Foundation

extension Float {
    func formattedString() -> String {
        let formatter = NumberFormatter()
        formatter.minimumFractionDigits = 0
        formatter.maximumFractionDigits = 8 // 根据需求设置最大小数位数

        if let formattedString = formatter.string(from: NSNumber(value: self)) {
            return formattedString
        } else {
            return "\(self)"
        }
    }
}

extension Double {
    func formattedString() -> String {
        let formatter = NumberFormatter()
        formatter.minimumFractionDigits = 0
        formatter.maximumFractionDigits = 8 // 根据需求设置最大小数位数

        if let formattedString = formatter.string(from: NSNumber(value: self)) {
            return formattedString
        } else {
            return "\(self)"
        }
    }
}


